package usaco;
/*
ID: teregg1
LANG: JAVA
TASK: milk
 */

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class milk {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new FileReader("usaco/milk.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("milk.out")));

		String line = in.readLine();
		int milkWanted = Integer.parseInt(line.split(" ")[0]);
		int farmersNum = Integer.parseInt(line.split(" ")[1]);
		
		int[][] priceAndAmount = new int[farmersNum][2];

		for (int i = 0; i < farmersNum; i++) {
			line = in.readLine();
			priceAndAmount[i][0] = Integer.parseInt(line.split(" ")[0]);
			priceAndAmount[i][1] = Integer.parseInt(line.split(" ")[1]);			
		}
		int cost = 0;
		if(milkWanted != 0){
			int idx = getMinIdx(priceAndAmount);
			int price;
			int product;
			
			boolean flag = true;
			
			while(flag){
				price = priceAndAmount[idx][0];
				product = priceAndAmount[idx][1];
				if((milkWanted - product) >= 0){
					milkWanted -= product;
					cost += price * product;
					if(milkWanted == 0){
						flag = false;
					}
				}else{
					
					cost += milkWanted * price;
					flag = false;
				}
				priceAndAmount[idx][0] = 10000;
				idx = getMinIdx(priceAndAmount);
			}
			
			System.out.println(cost);
		}else {
			System.out.println(0);
		}
		
		out.close();
		System.exit(0);
		
	}
	
	private static int getMinIdx(int[][] a){
		int min = 10000;
		int idx = 0;
		for (int i = 0; i < a.length; i++) {
			if(a[i][0] < min){
				min = a[i][0];
				idx = i;
			}
		}
		System.out.println("idx:  " + idx);
		return idx;
	}
}
